<?php

class Application_Model_ProfileMapper {

    public static function insert($profile) {
        $db = Zend_Registry::get("database");
        $date = array(
            C_NAME => $profile->getName(),
            C_ADDRESS => $profile->getAddress(),
            C_PHONE => $profile->getPhone(),
            C_ACCOUNT_ID => $profile->getAccountID()
        );
        $db->insert(T_PROFILE, $date);
        return $db->lastInsertId();
    }

    public static function getByEmail($email) {
        $db = Zend_Registry::get("database");
        return $db->fetchRow("SELECT * FROM ACCOUNT, PROFILE WHERE ACCOUNT.ID = PROFILE.ACCOUNT_ID AND EMAIL = '" . $email . "'");
    }

    public static function update($profile) {
        $db = Zend_Registry::get("database");
        $date = array(
            C_NAME => $profile->getName(),
            C_ADDRESS => $profile->getAddress(),
            C_PHONE => $profile->getPhone(),
        );
        $db->update(T_PRODUCT, $date, "ID=" . $profile->getID());
    }

}

